//index.js
//获取应用实例
const app = getApp()
import { Banner, notice, nine, categorys } from '../../utils/http'

Page({
  data: {
    show: true,
    time: 30 * 60 * 60 * 1000,
    image: [],
    notice: [],
    nine: [],
    ms: [],//限时秒杀
    bk: [],//爆款推荐
    xp: [],//小票
    kj: [],//砍价
    qm: [],
    // 商品列表
    goods: [],
    photo: [],
    value: '',
  },
  onLoad: function () {
    // console.log(this.data.xp)
    //轮播图
    Banner().then(res => {
      let image = this.data.image
      image = res.data
      let a = image.slice(3, 6)
      this.setData({ image: a, photo: res.data[1] })
    })
    // 通告
    notice().then(res => {
      this.setData({ notice: res.data.dataList })
    })
    // 九宫格
    nine().then(res => {
      this.setData({ nine: res.data })
   
    })
    //shangpin
    categorys().then(res => {
      console.log(res)
      let good = res.data
      this.setData({ ms: res.data[19], bk: res.data[25], xp: res.data[23], kj: res.data[22], qm: res.data[21], goods: good })
    })
  },
  searchChangeHandle(e) {
    console.log(e.detail)
    this.setData({ value: e.detail })
  },
  searchHandle() {
    let good=this.data.goods
    let goods=JSON.stringify(good)
    let val=this.data.value
    console.log(val)
    wx.reLaunch({
      url: "/pages/goodslist/goodslist?goods="+goods+`&val=`+val,
    })

  },
  jump(e){
    console.log(e)
    console.log(e.currentTarget.dataset.id)
    console.log(e.currentTarget.dataset.index)
    let id=e.currentTarget.dataset.id
    let index=e.currentTarget.dataset.index
    wx.reLaunch({
      url: '/pages/classify/classify?index='+index+'&id='+id,
    })
  }
})
